-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: debug and compare modes fix #390
Conversation
This pull request is automatically being deployed by Amplify Hosting (learn more). |
@@ -83,6 +81,8 @@ export const UploadPanel = ({ | |||
onFileUploaded, | |||
onFileEvent, | |||
}: UploadProps) => { | |||
const UPLOAD_INPUT_ID = useMemo(() => `upload-file-input${crypto.randomUUID()}`, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this fix? It would be good to have a list of changes in the PR description with screenshots when applicable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have several upload panels open at the same time (for example in comparison mode) all actions go to the first one and you're unable to choose a file on the second one. This happens because all file inputs and divs that catch the actions have the same id. This fix generates the unique id for every upload panel so actions will be passed inside every upload panel separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how randomUUID: () => ""
can return something unique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stab needs to be there because jsdom
doesn't have a stub for browser's crypto
. And since we don't have tests where two upload panels would be shown at the same time, so randomUUID: () => ""
is enough for all our tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid hacks?
The offered approach is very weird:
- We make a global variable that is bad practice;
- We declare
randomUUID
that doesn't return a UUID; - Why
crypto.reandomUUID
? Is there any reason to mock nodejs API?
For example, we can use Redux to generate unique application-wide integer ids.
@@ -83,6 +81,8 @@ export const UploadPanel = ({ | |||
onFileUploaded, | |||
onFileEvent, | |||
}: UploadProps) => { | |||
const UPLOAD_INPUT_ID = useMemo(() => `upload-file-input${crypto.randomUUID()}`, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid hacks?
The offered approach is very weird:
- We make a global variable that is bad practice;
- We declare
randomUUID
that doesn't return a UUID; - Why
crypto.reandomUUID
? Is there any reason to mock nodejs API?
For example, we can use Redux to generate unique application-wide integer ids.
I already moved the hack to test files, so chages requested needed to be done in another file
No description provided.